<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="/WEB-INF/tlds/c.tld" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>用户信息管理</title>
	<link rel="stylesheet" type="text/css" href="../css/index.css"></link>
	<script src="../js/common.js"></script>
	<script src="../js/jquery.plugins/jquery.js"></script>
	
	<link rel="stylesheet" type="text/css" href="../js/jquery.plugins/easyui/css/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="../js/jquery.plugins/easyui/css/icon.css"></link>
	<script src="../js/jquery.plugins/easyui/jquery.easyui.min.js"></script>
	<script src="../js/jquery.plugins/easyui/easyui-lang-zh_CN.js"></script>
	<script src="../js/page.js"></script>
	<script>
		$(function(){
			buildPage( ${pager.page},${pager.pageSize},${pager.totalNum} , '${pager.queryString}' );
			$('.pageDiv').pagination({
			buttons:[{
				iconCls:'icon-add',
				text:'添加用户',
				handler:function(){
					window.location.href='get.ht';
				}
			}]});
		});
		function findDepartment( companyId ){
			if( companyId == "" ){
				fillSelect( "query[departmentId]" );
				return false;
			}
			var param = "companyId=" + companyId;
			$.ajax({
				url:"/department/ajaxFindByCompany.ht",
				data:param,
				type:'post',
			    dataType:'json',
			    success:function(departments){
					fillSelect( "query_departmentId" , departments, "id","name" ,"全部部门...");
			}});
		}
	</script>
</head>
<body>
	<!-- 导航部分 -->
	<div class="position">
	您当前的位置：系统管理 &gt;&gt; <a href="list.ht">用户信息管理</a>
	</div>
	<!-- 导航部分结束 -->
	<!-- 搜索部分 -->
	<div style="float:right;margin-right:50px;">
		<form id="searchform" action="list.ht" method="post">
			<table class="search">
				<tr>
					<td>
					<label>用户名称:</label>
					<input type="text" name="query[keyword]" value="${pager.query['keyword']}" style="width:100px;"/>
					所属店铺：
					<select name="query[companyId]" id="query[companyId]" style="width:200px;"  onchange="findDepartment( this.value );">
					<option value="">全部店铺...</option>
						<c:forEach var="company" items="${companys}">
						<option value="${company.id}" <c:if test="${ company.id==pager.query['companyId']}">selected</c:if>><c:if test="${company.lev == 1}">&nbsp;&nbsp;</c:if>${company.name}</option>
						</c:forEach>
					</select>
					所属部门：
					<select name="query[departmentId]" id="query_departmentId" style="width:200px;">
					<option value="">全部部门...</option>
						<c:forEach var="department" items="${departments}">
						<option value="${department.id}" <c:if test="${ department.id ==pager.query['departmentId']}">selected</c:if>>${department.name}</option>
						</c:forEach>
					</select>
					<button class="small-btn" type="submit">搜索</button>
					<button class="medium-btn" type='button' onclick="forward('get.ht');">添加用户</button>
				
					</td>
				</tr>
			</table>
		</form>
	</div>
	<div class="clear"></div>
	<!-- 搜索部分结束 -->
	
	<!-- 列表部分 -->
	<!-- 分页 -->
	<div class="pageDiv"></div>
	<!-- 分页结束 -->
	<table class="list">
		<thead>
			<tr>
			<th>用户名</th>
			<th>email</th>
			<th>电话</th>
			<th>手机</th>
			<th>地址</th>
			<th>所属部门</th>
			<th>状态</th>
			<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="user" items="${ models }">
			<tr>
				<td>${user.name }</td>
				<td>${user.email }</td>
				<td>${user.tel }</td>
				<td>${user.mobile }</td>
				<td>${user.address }</td>
				<td>${user.department.name }</td>
				<td><c:choose>
						<c:when test="${user.status==true}"><font class="pass">启用</font></c:when>
						<c:otherwise><font class="error">禁止登陆</font></c:otherwise>
					</c:choose></td>
				<td>
				<a href="status.ht?id=${user.id}"><c:choose><c:when test="${user.status==true}">禁止登陆</c:when><c:otherwise>启用登陆</c:otherwise></c:choose></a>
				| <a href="get.ht?id=${user.id}">修改</a> | <a href="javascript:toconfirm('delete.ht?id=${user.id}');">删除</a></td>
			</tr>
			</c:forEach>
		</tbody>
	</table>
	<!-- 分页 -->
	<div class="pageDiv"></div>
	<!-- 分页结束 -->
	<!-- 列表部分结束 -->
</body>
</html>